//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CSimpleGeometry10.h>
///	@path	~/src/graphics/dx10/
///	@date	2008/12/28
///	@desc	.

#pragma once

#include "xeres.h"

#include "graphics/IGeometry.h"
#include "graphics/dx10/CDevice10.h"
#include "graphics/dx10/CVertexLayout10.h"

namespace xeres {

	/*!
		\class	CSimpleGeometry10
		\brief	Very low-level and very basic implementation.
				Draws very simple geometry objects.
	*/
	class CSimpleGeometry10 : public IGeometry
	{
	public:

		/// \ctor
		CSimpleGeometry10( Ref<CVertexLayout10> layout , size_t stride , size_t vertex_count , size_t count , D3D10_PRIMITIVE_TOPOLOGY type ,
			ID3D10Buffer * vertex , ID3D10Buffer * index );

		/// \dtor
		virtual ~CSimpleGeometry10( void );

		DECL_IOBJECT_CLASS( CSimpleGeometry10 , IGeometry );

	public:

	//@ interface

		/*!
			\brief		Called when device is lost or before reset.
		*/
		virtual bool OnLostDevice( void );

		/*!
			\brief		Called after device is reset.
		*/
		virtual bool OnResetDevice( RefWeak<IDevice> device );

		/*! 
			\brief		Get geometry vertex layout.
		*/
		virtual RefWeak<IVertexLayout> GetLayout( void );

		/*! 
			\brief		Prepare draw (apply vertex & index buffer).
		*/
		virtual void EstablishBuffer( RenderContext& rc );

		/*!
			\brief		Draw geometry.
		*/
		virtual void Draw( RenderContext& rc );

	private:

	//@ data

		// vertex stride
		ushort					m_stride;

		// polygon is strip
		short					m_type;

		// primitive count
		size_t					m_count;

		// vertex count
		size_t					m_vertexCount;

		// vertex layout
		Ref<CVertexLayout10>	m_layout;

		// directly access to buffer

		// vertex buffer
		ID3D10Buffer *			m_pVertexBuffer;

		// index buffer
		ID3D10Buffer *			m_pIndexBuffer;

	};

} // namespace xeres
